package com.ruoyi.web.controller.community.notice;

import java.util.List;

import com.ruoyi.community.domain.NoticeSection;
import com.ruoyi.community.domain.SimpleNoticeSection;
import com.ruoyi.community.domain.BaseNoticeSection;
import com.ruoyi.community.service.IBaseNoticeSectionService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公告板块Controller
 *
 * @author ruoyi
 * @date 2021-12-21
 */
@RestController
@RequestMapping("/community/notice/section")
public class NoticeSectionController extends BaseController
{
    @Autowired
    private IBaseNoticeSectionService baseNoticeSectionService;

    /**
     * 查询公告板块列表
     */
    @GetMapping("/list")
    public AjaxResult list(BaseNoticeSection baseNoticeSection)
    {
        List<BaseNoticeSection> list = baseNoticeSectionService.selectBaseNoticeSectionList(baseNoticeSection);
        return AjaxResult.success(list);
    }

//    /**
//     * 获取公告板块详细信息
//     */
//    @GetMapping(value = "/{sectionId}")
//    public AjaxResult getInfo(@PathVariable("sectionId") String sectionId)
//    {
//        return AjaxResult.success(baseNoticeSectionService.selectBaseNoticeSectionById(sectionId));
//    }

    /**
     * 新增公告板块
     */
    @PreAuthorize("@ss.hasPermi('community:section:add')")
    @Log(title = "公告板块", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseNoticeSection baseNoticeSection)
    {
        return toAjax(baseNoticeSectionService.insertBaseNoticeSection(baseNoticeSection));
    }

    /**
     * 删除公告板块
     */
    @PreAuthorize("@ss.hasPermi('community:section:remove')")
    @Log(title = "公告板块", businessType = BusinessType.DELETE)
    @DeleteMapping("/{sectionIds}")
    public AjaxResult remove(@PathVariable String[] sectionIds)
    {
        return toAjax(baseNoticeSectionService.deleteBaseNoticeSectionByIds(sectionIds));
    }
}
